places sidebar: compare bookmarks by index
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Wed, 4 Mar 2015 20:12:40 +0000 (17:12 -0300)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Wed, 4 Mar 2015 20:20:40 +0000 (17:20 -0300)
GtkPlacesSidebar applies a sorting function on
the tree model that does not consider the case
of bookmarks, which are sorted by their indexes.

By adding the bookmarks corner case and comparing
then by their indexes, GtkPlacesSidebar can sort
the bookmarks properly in the order they're saved.

https://bugzilla.gnome.org/show_bug.cgi?id=744589

gtk/gtkplacessidebar.c

index fecb94f0a2d0b86bf524d703bb2ff2af51526357..e9d220edbf4b98ec51a96780f0ff8e4b1fca5906 100644 (file)
@@ -3830,6 +3830,20 @@ places_sidebar_sort_func (GtkTreeModel *model,
       g_free (name_a);
       g_free (name_b);
     }
+  else if ((place_type_a == place_type_b) &&
+           (place_type_a == PLACES_BOOKMARK))
+    {
+      gint pos_a, pos_b;
+
+      gtk_tree_model_get (model, iter_a,
+                          PLACES_SIDEBAR_COLUMN_INDEX, &pos_a,
+                          -1);
+      gtk_tree_model_get (model, iter_b,
+                          PLACES_SIDEBAR_COLUMN_INDEX, &pos_b,
+                          -1);
+
+      retval = pos_a - pos_b;
+    }
   else if (place_type_a == PLACES_CONNECT_TO_SERVER)
     {
       retval = 1;